home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Tele / C / Comet2.1.3.cpt / include / net.h < prev    next >
Text File  |  1990-07-26  |  5KB  |  149 lines

  1. /*  Copyright 1983 by the Massachusetts Institute of Technology  */
  2.  
  3. /*
  4.     Copyright Cornell University 1986.  All rights are reserved.
  5.  
  6.     As of 4/10/86:
  7.     This source file may have no changes from the M.I.T original
  8.     other than this notice; but it has been tested as part of 
  9.     Cornell's Aztec-C port.  See notice.h
  10.  
  11. */
  12.  
  13. /*  define's for levels of tracing and for success and failure
  14.     added, January 1984.     <J. H. Saltzer>
  15.     8/12/84 - added the custom structure for each net, and RARP
  16.                     <John Romkey>
  17.     10/3/84 - changed the Q to a queue * to make structure
  18.         initialization simpler.    <John Romkey>
  19. */
  20. /* 10/24/87 kevin added rnet NET * */
  21. /* 4/20/88 kevin added GH defines */
  22.  
  23. #ifndef    _NETDEF
  24.  
  25. #define _NETDEF
  26.  
  27. /* need to define this before dragging in custom.h */
  28.  
  29. #include <task.h>
  30. #include <q.h>
  31. #include <netq.h>
  32. #include <custom.h>
  33.  
  34. /* This is the net structure. This idea is based somewhat on Noel's C
  35.     Gateway. For the IBM's, we need an easy way to make up a net
  36.     program that can use any of the three potential nets that the
  37.     IBM can be interfaced to: the Serial Line net w/PC Gateway, the
  38.     10 Mb Ethernet or a Packet Radio setup.
  39.        The code for each net has to supply a routine to send packets
  40.     over the net, a routine to receive packets and a routine to
  41.     do net initialization. The init routine finds the IBM's address
  42.     on that net. All addresses are internet addresses; any local
  43.     addresses can be kept in statics by the net drivers.
  44.        To use this, the user creates a C program which just consists
  45.     of the global structure called nets which is an array of net structs.
  46.     The netinit routine will do the right thing with all the info provided
  47.     when called, and will call each net's initialization routines.
  48.     The user must include a variable, int Nnet, in this file with the
  49.     statement:
  50.         int Nnet = sizeof(nets)/sizeof(struct net);
  51.     This provides a way for netinit to tell how many nets there are. */
  52.  
  53.  
  54. #define    IP    0
  55. #define    CHAOS    1
  56. #define    PUP    2
  57. #define ARP 3
  58.  
  59. /* stanford defines */
  60. #define    SLP    3
  61. #define    ADR    4    /* Dave Plummer's Address Resolution Protocol */
  62. #define    RARP    5    /* reverse address resolution protocol */
  63.  
  64. typedef long in_name;
  65.  
  66. /* The NET struct has all the actual interface characteristics which are
  67.     visible at the internet level and has pointers to the interface
  68.     handling routines.    */
  69.  
  70. struct net {
  71.     char    *n_name;    /* 00 the net's name in ascii */
  72.     int    (*n_init)();    /* 04 the net initialization routine */
  73.     int    (*n_send)();    /* 08 the packet xmit routine */
  74.     int    (*n_open)();    /* 12 the protocol open routine */
  75.     int    (*n_close)();    /* 16 the protocol close routine */
  76.     task    *n_demux;    /* 20 packet demultiplexing task to protocol */
  77.     queue    *n_inputq;    /* 24 the queue of received packets */
  78.     unsigned n_initp1;    /* 28 initialization parameter one */
  79.     unsigned n_initp2;    /* 30    "         "        two */
  80.     int    n_stksiz;    /* 32 net task initial stack size */
  81.     int    n_lnh;        /* 34 the net's local net header  size */
  82.     int    n_lnt;        /* 36 the net's local net trailer size */
  83.     in_name    ip_addr;    /* 38 the interface's internet address */
  84.     int    (*n_stats)();    /* 42 ... per net statistics */
  85.     in_name n_defgw;    /* 46 the default gateway for this net */
  86.     struct custom    *n_custom;    /* 50 net's custom structure */
  87.     int    (*n_susp)();    /* 54 protocol suspend routine for Switcher */
  88.     int    (*n_subnet)();    /* 58 protocol subnet routine */
  89. };
  90.  
  91.  
  92. typedef struct net NET;
  93.  
  94. /* Here are the debugging things. DEBUG is a global variable whose value
  95.     determines what sort of debugging messages will be displayed by
  96.     the system. */
  97.  
  98. extern unsigned NDEBUG;        /* Debugging options */
  99. extern int MaxLnh;        /* Largest local net header size */
  100. extern unsigned version;    /* program version number */
  101. extern int Nnet;
  102. extern NET * rnet;
  103. extern NET nets[];
  104. extern int netid;            /* offset into nets[] of current net */
  105.  
  106. #define    BUGHALT        1    /* BUGHALT on a gross applications level error
  107.                     that is detected in the network code */
  108.  
  109. #define    DUMP        2    /* Do a dump of all bad incoming packets */
  110.  
  111. #define    INFOMSG        4    /* Print informational messages such as packet
  112.                     received, etc. */
  113.  
  114. #define    NETERR        8    /* Display net interface error messages */
  115.  
  116. #define    PROTERR        16    /* Display protocol level error messages */
  117.  
  118. #define    TRACE        32    /* Trace packet through protocol layers */
  119.  
  120. #define NETRACE        32    /* Trace packet in link level net layer */
  121.  
  122. #define INTRACE        32    /* Trace packet in internet layer  */
  123.  
  124. #define TCTRACE        32    /* Transmission control (UDP, TCP) trace */
  125.  
  126. #define APTRACE        128    /* Trace packet through application */
  127.  
  128. #define    TMO        64    /* Print message on timeout */
  129.  
  130. #define    ROUTE        128    /* turn on routing tracing */
  131.  
  132. #define    TCPTRACE    256
  133.  
  134. /*  The following two definitions provide a standard way for one net level
  135. to tell the next that things worked out as hoped or that they didn't.  */
  136.  
  137. #define SUCCESS        1
  138.  
  139. #define FAILURE        -1
  140.  
  141. /* flags for get_host, which button to highlight */
  142. #define GH_OPEN    1
  143. #define GH_QUIT    2
  144. #define GH_SET    3
  145.  
  146.  
  147. #endif
  148.  
  149.